/**
 * 
 */
package com.gosophia.conference.action.starting;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.security.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.conferenceManagement.ConferenceConfiguration;
import com.gosophia.conferenceManagement.starting.dto.ConferenceStartingDTO;
import com.gosophia.oa.action.JudgeCurrentUndertaker;
import com.gosophia.springsecurity.UserDetailsImpl;
import com.gosophia.taskManagement.dto.JobDTO;
import com.gosophia.taskManagement.ws.TaskManagementWebService;

/**
 * 功能：进入直接发起会议页面
 * 
 * @author tianchunyu
 * @since 2011-3-23 Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@Controller("EnterStartingWithNoApplicationAction")
@Scope("prototype")
public class EnterStartingWithNoApplicationAction extends BaseSupportAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Long jobId;
	private ConferenceStartingDTO conferenceStartingDTO;

	@Autowired
	private TaskManagementWebService taskManagementWebService;
	@Autowired
	private JudgeCurrentUndertaker judgeCurrentUndertaker;

	@Override
	public String _execute() throws Exception {
		// 得到当前用户
		UserDetailsImpl userDetails = (UserDetailsImpl) SecurityContextHolder
				.getContext().getAuthentication().getPrincipal();
		Long creatorId = userDetails.getUserAccountDTO().getUserInfoDTO()
				.getUserInfoId();

		if (jobId != null) {
			judgeCurrentUndertaker.judgeOperationAuthority(jobId);
		}
		if (jobId != null) {
			JobDTO jobDto = taskManagementWebService
					.findJobDetailByJobId(jobId);
			conferenceStartingDTO = new ConferenceStartingDTO();
			conferenceStartingDTO.setConferenceCreatorId(creatorId);
			conferenceStartingDTO
					.setConferenceModel(ConferenceConfiguration.NO_APPLICATION_CONFERENCE);
			conferenceStartingDTO.setConferenceName(jobDto.getMissionDTO()
					.getMissionName());
			conferenceStartingDTO.setImportentLevel(jobDto.getMissionDTO()
					.getImportanceDTO().getDataValueId());
			conferenceStartingDTO.setPlanEndTime(jobDto.getMissionDTO()
					.getScheduleEndDate());
			conferenceStartingDTO.setConferenceDescription(jobDto
					.getMissionDTO().getDescription());
			conferenceStartingDTO.setJobId(jobId);
		}
		return SUCCESS;
	}

	public Long getJobId() {
		return jobId;
	}

	public void setJobId(Long jobId) {
		this.jobId = jobId;
	}

	public ConferenceStartingDTO getConferenceStartingDTO() {
		return conferenceStartingDTO;
	}

	public void setConferenceStartingDTO(
			ConferenceStartingDTO conferenceStartingDTO) {
		this.conferenceStartingDTO = conferenceStartingDTO;
	}

}
